using System.Collections.Generic;
using UnityEngine;

public class SkinManager : MonoBehaviour
{
	public enum EventName
	{
		None,
		Halloween,
		Christmas,
		LunarNewYear,
		ValentinDay,
		Easter,
		Summer
	}

	public static SkinManager Instance;

	public List<SkinParameters> Skins;

	private Dictionary<string, int> gameCountPerSkin = new Dictionary<string, int>();

	private void Awake()
	{
		Instance = this;
	}

	public SkinParameters GetSkinWithIndex(int index)
	{
		return Skins.Find((SkinParameters s) => s.skinIndex == index);
	}

	public SkinParameters GetSkinWithStoreID(string id)
	{
		return Skins.Find((SkinParameters s) => s.storeID == id);
	}

	public void UnlockSkinWithAchievement(int index)
	{
		if (!PlayerData.Instance.IsSkinUnlocked(index))
		{
			PlayerData.Instance.SetSkinUnlocked(index);
			PlayerData.Instance.SaveData();
			SkinParameters skinWithIndex = GetSkinWithIndex(index);
			App.Instance.hasUnlockedSkin = true;
			UISkinNotification.Instance.ShowNotification(new UISkinNotification.NotificationContentUnlock(skinWithIndex));
		}
	}

	public void UnlockSkinWithIAP(int index)
	{
		if (!PlayerData.Instance.IsSkinUnlocked(index))
		{
			PlayerData.Instance.SetSkinUnlocked(index);
			PlayerData.Instance.SaveData();
			SkinParameters skinWithIndex = GetSkinWithIndex(index);
			UISkinNotification.Instance.ShowNotification(new UISkinNotification.NotificationContentBuy(skinWithIndex));
		}
	}

	public void RegisterSkinUse(int index)
	{
		PlayerData.Instance.RegisterSkinUse(index);
		int num = 0;
		foreach (SkinParameters skin in Skins)
		{
			if (!skin.isDefaultSkin && PlayerData.Instance.HasUsedSkin(skin.skinIndex))
			{
				num++;
			}
		}
		AchievementManager.Instance.SetPersistentData(AchievementKeys.SkinUsed, num);
	}
}
